package com.gdkj.common;

import com.alibaba.fastjson.JSONObject;
import com.xjgks.common.response.HttpResult;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class BussCommonResponse {
    public static void print(HttpServletResponse response, HttpResult resultData) throws IOException {
        response.setCharacterEncoding("UTF-8");
        response.setHeader("Content-Type", "application/json");
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, PATCH, DELETE");
        response.setHeader("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type");
        response.setHeader("Access-Control-Allow-Credentials", "true");
        PrintWriter printWriter = response.getWriter();
        printWriter.write(JSONObject.toJSONString(resultData));
        printWriter.flush();
    }
}
